package cj.web.admin.dao;

import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.GameOrder;

/**
 * 
 * @author 
 *
 */
@DAO
public interface ShowGameOrderDAO{
	
	@SQL("select code From GameOrder WHERE deleteFlag=1 #if(:t.gameId!=''){ and gameId =:t.gameId } Group By code Having count(*)>1 LIMIT :t.start,:t.length ")
    List<GameOrder> queryShowGameOrder(@SQLParam("t") GameOrder gameOrder);
	
	@SQL("select count(1) from (select code From GameOrder WHERE deleteFlag=1 #if(:t.gameId!=''){ and gameId =:t.gameId } Group By code Having count(*)>1) a ")
	int queryShowGameOrderSize(@SQLParam("t") GameOrder gameOrder);
	
	@SQL("select * from GameOrder where deleteFlag=1 #if(:t.gameId!=''){ and gameId =:t.gameId } #if(:t.code!=''){ and code like '%##(:t.code)%' } ORDER BY createAt DESC LIMIT :t.start,:t.length ")
    List<GameOrder> query(@SQLParam("t") GameOrder gameOrder);
	
	@SQL("SELECT count(*) FROM GameOrder WHERE deleteFlag=1 #if(:t.gameId!=''){ and gameId =:t.gameId } #if(:t.code!=''){ and code like '%##(:t.code)%' } ")
    int querysize(@SQLParam("t") GameOrder gameOrder);
    
    @SQL("UPDATE GameOrder SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
    
    @SQL("UPDATE GameOrder SET deleteFlag=1 WHERE id=:1")
    void recoverById(int id);
}